package com.xcjw.com.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xcjw.com.Bean.CarSearchBean;
import com.xcjw.com.R;

import java.util.List;

/**
 * @packname com.xcjw.com.Adapter
 * @filename MyDocumentAdapter
 * @date on 2018/11/22 20:04
 *****/
public class MyDocumentAdapter  extends BaseAdapter{

      private Context context;
      private List<CarSearchBean.ContentBean.CarTypeListBean> list;

      public MyDocumentAdapter(Context context,  List<CarSearchBean.ContentBean.CarTypeListBean> list) {
            this.context = context;
            this.list = list;
      }

      @Override
      public int getCount() {
            return list.size() >0? list.size() :0;

      }

      @Override
      public Object getItem(int position) {
            return list.get(position);
      }

      @Override
      public long getItemId(int position) {
            return position;
      }

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
            DocumentHolder holder = null;
            if (convertView == null) {
                  convertView = LayoutInflater.from(context).inflate(R.layout.document_item, parent, false);
                  holder = new DocumentHolder();
                  holder.textView = (TextView) convertView.findViewById(R.id.content);
                  convertView.setTag(holder);
            } else {
                  holder = (DocumentHolder) convertView.getTag();
            }
            holder.textView.setText(list.get(position).getCarType());
            return convertView;
      }

      class DocumentHolder {
            TextView textView;

      }
}